package com.by.service.impl;

import com.by.bean.Customer;
import com.by.common.crud.BaseServiceImpl;
import com.by.common.utils.Assert;
import com.by.mapper.CustomerMapper;
import com.by.mapper.UserMapper;
import com.by.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author wang
 * @version 版本号 ${}
 * @className CustomerServiceImpl
 * @日期 2024/9/13 15:56
 * @since jdk1.8
 */
@Service
public class CustomerServiceImpl extends BaseServiceImpl<Customer, CustomerMapper> implements CustomerService {
    
    @Autowired
    UserMapper userMapper;
    
    @Override
    public int save(Customer entity) {
        //保存用户
        entity.getUser().setType(4);
        int rs = userMapper.save(entity.getUser());
        Assert.isNotSuccess(rs, "用户保存失败");
        //用户保存成功
        //保存员工
        return super.save(entity);
    }
}
